package com.deliveryservicesystem.model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 * File Name: Billing.java
 * Version:
 * Description:
 * Package: com.deliveryservicesystem.model.newpackage
 * Author: Lance
 * Date: Jun 24, 2012
 * Editor:
 */
@Entity
@Table(name = "BILLING")
@XmlRootElement
@NamedQueries(
{
    @NamedQuery(name = "Billing.findAll", query = "SELECT b FROM Billing b"),
    @NamedQuery(name = "Billing.findByBillingNo", query = "SELECT b FROM Billing b WHERE b.billingNo = :billingNo"),
    @NamedQuery(name = "Billing.findByBillingAddress", query = "SELECT b FROM Billing b WHERE b.billingAddress = :billingAddress"),
    @NamedQuery(name = "Billing.findByBillingAmount", query = "SELECT b FROM Billing b WHERE b.billingAmount = :billingAmount")
})
public class Billing implements Serializable
{

    private static final long serialVersionUID = 1L;
    @Id
    @SequenceGenerator(name = "SEQ_BILLING_NO", sequenceName = "SEQ_BILLING_NO")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_BILLING_NO")
    @Basic(optional = false)
    @Column(name = "BILLING_NO")
    private Integer billingNo;
    @Column(name = "BILLING_ADDRESS")
    private String billingAddress;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "BILLING_AMOUNT")
    private double billingAmount;
    @OneToMany(mappedBy = "billingNo")
    private List<Subscription> subscriptionList;

    public Billing()
    {
    }

    public Billing(Integer billingNo)
    {
        this.billingNo = billingNo;
    }

    public Integer getBillingNo()
    {
        return billingNo;
    }

    public void setBillingNo(Integer billingNo)
    {
        this.billingNo = billingNo;
    }

    public String getBillingAddress()
    {
        return billingAddress;
    }

    public void setBillingAddress(String billingAddress)
    {
        this.billingAddress = billingAddress;
    }

    public double getBillingAmount()
    {
        return billingAmount;
    }

    public void setBillingAmount(double billingAmount)
    {
        this.billingAmount = billingAmount;
    }

    @XmlTransient
    public List<Subscription> getSubscriptionList()
    {
        return subscriptionList;
    }

    public void setSubscriptionList(List<Subscription> subscriptionList)
    {
        this.subscriptionList = subscriptionList;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (billingNo != null ? billingNo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Billing))
        {
            return false;
        }
        Billing other = (Billing) object;
        if ((this.billingNo == null && other.billingNo != null) || (this.billingNo != null && !this.billingNo.equals(other.billingNo)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "Billing Number: " + billingNo
                + "\nBilling Address: " + billingAddress
                + "\nBilling Amount: " + billingAmount;
    }
}
